The present invention relates generally to database systems, and more particularly to a system for automatically generating database diagrams depicting neighborhoods of database tables related to a selected database table.
A relational database is a collection of data that is logically organized in related two-dimensional tables of columns and rows. A database may contain numerous tables each of which may have several logical relationships to other tables in the database.
For software engineers developing software to interact with a database, as well as individuals involved with designing and/or maintaining a database, it is often very useful to view a graphical representation of the database with which they are working. A graphical representation of a database, frequently referred to as a xe2x80x9cdatabase diagramxe2x80x9d depicts database tables as well as the relationships that exist between tables. A database diagram helps developers visualize structures of tables and relationships and thereby provides insights into the most efficient method of accessing a desired set of data and modifications that may need to be made to the database. Indeed, one of the first tasks a software developer will frequently perform when assigned to a new project is to view the database diagram for the database to which they will be developing.
Databases are frequently very complex and may contain hundreds of tables with hundreds of inter-relationships. A database diagram reflects the complexity and size of the underlying database. Indeed, for many complex databases the related database diagram cannot be viewed on one computer screen or printed on a single sheet of paper. Rather, viewing a complex database diagram on-line often requires paging between numerous screens and a printout of a database diagram may cover an entire wall.
Thus, due to the number of database tables and the complexity of relationships between tables, database diagrams can be unwieldy and confusing. For this reason, it is often useful to view selected portions of a database diagram. Specifically it is useful to view a specific database table and those tables that are related to the specific table. For example, a developer building an application related to an organization""s employees may desire to focus attention on only those database tables related to employees. The tables related to employees are those that will most frequently be accessed and it is the structure and relationships of these tables that is most important for the developer to critically understand. Therefore, in such a situation, a developer may wish to have a database diagram depicting the xe2x80x9cneighborhoodxe2x80x9d of tables related to employees.
Existing database diagramming tools provide the capability to build a database diagram for an entire database. In order to view only a portion of the database diagram for a database, such as a table neighborhood, however, it is necessary to build the diagram for the entire database and thereafter manually remove the tables and relationships that are not desired. The task of removing tables is manually taxing and time consuming, and introduces human error into the generation of a database diagram.
Thus, there is a need for a database system which provides the capability to automatically build database diagrams featuring only selected neighborhoods of an entire database. Specifically, there is a need for a database system wherein a specific table may be selected and a database diagram automatically generated featuring the selected table and all database tables having a direct relation to the selected table. Preferably the system also provides the capability to view in a database diagram additional tables that have indirect relationships, i.e. tables related to any tables having a direct relation to the selected table. Additionally, the system should provide the capability to select two or more tables for which it is desired to have database diagrams automatically generated.
Briefly, the present invention is directed toward remedying these shortcomings by automatically generating database diagrams for selected neighborhoods of tables.
According to the invention, a database management system comprises a xe2x80x9cdatabase designer.xe2x80x9d The database designer provides the capability for users to selectively define the parameters for the database diagram that they wish to see. More specifically, the database designer allows users to select a table and specify a level of relation for related tables which are also desired to be included in the database diagram. A user may specify to include in the database diagram tables that are several relationships removed from the selected table. Upon selection of these parameters, the database designer automatically displays the selected database table and related database tables having the selected level of relation with the selected database table.
According to another aspect of the invention, there is provided a method of creating a database diagram for a selected database table. The method for creating a database diagram comprises searching a database for tables having a relationship to a selected table. This step may entail searching several levels to compile a set of tables including tables that are several relations removed from the selected table. Thereafter, format data about the selected table and each table having the desired relationship to the selected table is retrieved. Finally, a graphical representation is displayed comprising the following elements: the selected table, each table falling with in the desired relationship to the selected table, and relationships existing there between.